﻿using System;
using BaseRepository.Cache;
using Microsoft.Extensions.DependencyInjection;

namespace Extensions.Services;

public static class AddMemoryCache
{
    public static IServiceCollection AddMemoryCacheSetup(this IServiceCollection service)
    {
       // 缓存的options一般不配置 因为统计缓存的大小  比较消耗性能 所以不设置缓存的大小
        ArgumentNullException.ThrowIfNull(service);
        service.AddMemoryCache()
            .AddScoped<ICacheRepository,CacheRepository>();
        return service;
    }
}